package com.xique.park.service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xique.common.core.utils.DateUtils;
import com.xique.park.bean.domain.ParkDeviceOnlineLog;
import com.xique.park.mapper.ParkDeviceOnlineLogMapper;
import com.xique.park.service.service.IParkDeviceOnlineLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 设备上下线日志记录Service业务层处理
 *
 * @author xique
 * @date 2021-12-09
 */
@Service
public class ParkDeviceOnlineLogServiceImpl implements IParkDeviceOnlineLogService {

    @Autowired
    private ParkDeviceOnlineLogMapper parkDeviceOnlineLogMapper;

    /**
     * 查询设备上下线日志记录
     *
     * @param id 设备上下线日志记录ID
     * @return 设备上下线日志记录
     */
    @Override
    public ParkDeviceOnlineLog selectParkDeviceOnlineLogById(Long id) {
        return parkDeviceOnlineLogMapper.selectById(id);
    }

    /**
     * 查询设备上下线日志记录列表
     *
     * @param parkDeviceOnlineLog 设备上下线日志记录
     * @return 设备上下线日志记录
     */
    @Override
    public List<ParkDeviceOnlineLog> selectParkDeviceOnlineLogListV2(ParkDeviceOnlineLog parkDeviceOnlineLog) {
        QueryWrapper<ParkDeviceOnlineLog> wrapper = new QueryWrapper<>();
        return parkDeviceOnlineLogMapper.selectList(wrapper);
    }

    @Override
    public List<ParkDeviceOnlineLog> selectParkDeviceOnlineLogList(ParkDeviceOnlineLog parkDeviceOnlineLog) {
        return parkDeviceOnlineLogMapper.selectParkDeviceOnlineLogList(parkDeviceOnlineLog);
    }

    /**
     * 新增设备上下线日志记录
     *
     * @param parkDeviceOnlineLog 设备上下线日志记录
     * @return 结果
     */
    @Override
    public int insertParkDeviceOnlineLog(ParkDeviceOnlineLog parkDeviceOnlineLog) {
        parkDeviceOnlineLog.setCreateTime(DateUtils.getNowDate());
        return parkDeviceOnlineLogMapper.insert(parkDeviceOnlineLog);
    }

    /**
     * 修改设备上下线日志记录
     *
     * @param parkDeviceOnlineLog 设备上下线日志记录
     * @return 结果
     */
    @Override
    public int updateParkDeviceOnlineLog(ParkDeviceOnlineLog parkDeviceOnlineLog) {
        parkDeviceOnlineLog.setUpdateTime(DateUtils.getNowDate());
        return parkDeviceOnlineLogMapper.updateById(parkDeviceOnlineLog);
    }

    /**
     * 批量删除设备上下线日志记录
     *
     * @param ids 需要删除的设备上下线日志记录ID
     * @return 结果
     */
    @Override
    public int deleteParkDeviceOnlineLogByIds(Long[] ids) {
        return parkDeviceOnlineLogMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除设备上下线日志记录信息
     *
     * @param id 设备上下线日志记录ID
     * @return 结果
     */
    @Override
    public int deleteParkDeviceOnlineLogById(Long id) {
        return parkDeviceOnlineLogMapper.deleteById(id);
    }
}
